//
//  ttViewController.m
//  UIHomework_2016.5.13
//
//  Created by dllo on 16/5/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ttViewController.h"
#import "TwooftwoViewController.h"
#import "TwooofoneViewController.h"
@interface ttViewController ()
@property (nonatomic, retain) TwooofoneViewController *viewofrefresh;
@property (nonatomic, retain) TwooftwoViewController *viewofstate;
@end

@implementation ttViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self config];
    }
    
    
    return self;
    
}
- (void)config{
    
    self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"主页" image:[UIImage imageNamed:@"unknown.png"] tag:100];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createsegview];
    [self createseg];
    self.view.backgroundColor = [UIColor grayColor];
}

- (void)createseg{
    UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"更新", @"动态"]];
    self.navigationItem.titleView = seg;
    [seg addTarget:self action:@selector(exchange:) forControlEvents:UIControlEventValueChanged];
    seg.selectedSegmentIndex = 0;



}

- (void)createsegview{
    self.viewofrefresh = [[TwooofoneViewController alloc] init];
    self.viewofrefresh.view.frame = CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64);
    self.viewofrefresh.view.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:self.viewofrefresh.view];

    
    self.viewofstate = [[TwooftwoViewController alloc] init];
    self.viewofstate.view.frame = CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64);
    self.viewofstate.view.backgroundColor = [UIColor purpleColor];
    [self.view addSubview:self.viewofstate.view];
    [self.view sendSubviewToBack:self.viewofstate.view];
  }
- (void)exchange:(UISegmentedControl *)segment{
    switch (segment.selectedSegmentIndex) {
        case 0:
            [self.view bringSubviewToFront:self.viewofrefresh.view];
            break;
            case 1:
            [self.view bringSubviewToFront:self.viewofstate.view];
        default:
            break;
    }




}













@end
